package Stack_04.BasedOnTheLinkedList_02;

/*
 * @Author 罗
 * @date 2020/3/13 - 8:54 下午
 *
 */
import org.junit.Test;

import java.util.Scanner;

public class test {

    @Test
    public void test(){
        StackBasedOnTheLinkedList stack = new StackBasedOnTheLinkedList();


        Scanner scanner = new Scanner(System.in);
        char key;
        boolean loop = true;
        while(loop){
            System.out.println("p:push()");
            System.out.println("e:exit");
            System.out.println("s:show()");
            System.out.println("c:pop()");
            System.out.println("请输出操作指令");
            key = scanner.nextLine().charAt(0);
            switch (key){
                case 'p' :{
                    System.out.println("请输入要push的内容");
                    String temp = scanner.nextLine();
                    stack.push(new ObjectNode<String>(temp));
                }break;
                case 'e' :{

                    loop = false;
                }break;
                case 's' :{
                    stack.show();
                }break;
                case 'c' :{
                    System.out.println(stack.pop());
                }break;
            }
        }
        scanner.close();
        System.out.println("Scanner已关闭");
    }
}
